<!DOCTYPE html>
<html>
<head><meta name="generator" content="Hexo 3.8.0">
    

    

    



    <meta charset="utf-8">
    
    
    
    
    <title>vue-源码笔记 | lafen | lafen&#39;s personal blog</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    
    <meta name="theme-color" content="#3F51B5">
    
    
    <meta name="keywords" content="learning,note,vue">
    <meta name="description" content="vue中操作类型判断 快速检查是否是一个对象类型  123function isObject (obj) &amp;#123;    return obj !== null &amp;amp;&amp;amp; typeof obj === &apos;object&apos;&amp;#125;  快速检查类型，利用 toString ，然后使用 slice 截取关键字  123456789101112131415var _toString =">
<meta name="keywords" content="learning,note,vue">
<meta property="og:type" content="article">
<meta property="og:title" content="vue-源码笔记">
<meta property="og:url" content="https://lafen.gitee.io/2019/11/17/vue-源码笔记/vue-源码笔记/index.html">
<meta property="og:site_name" content="lafen">
<meta property="og:description" content="vue中操作类型判断 快速检查是否是一个对象类型  123function isObject (obj) &amp;#123;    return obj !== null &amp;amp;&amp;amp; typeof obj === &apos;object&apos;&amp;#125;  快速检查类型，利用 toString ，然后使用 slice 截取关键字  123456789101112131415var _toString =">
<meta property="og:locale" content="zh-CN">
<meta property="og:updated_time" content="2019-11-24T06:57:04.131Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="vue-源码笔记">
<meta name="twitter:description" content="vue中操作类型判断 快速检查是否是一个对象类型  123function isObject (obj) &amp;#123;    return obj !== null &amp;amp;&amp;amp; typeof obj === &apos;object&apos;&amp;#125;  快速检查类型，利用 toString ，然后使用 slice 截取关键字  123456789101112131415var _toString =">
    
        <link rel="alternate" type="application/atom+xml" title="lafen" href="/atom.xml">
    
    <link rel="shortcut icon" href="/img/favicon.ico">
    <link rel="stylesheet" href="//unpkg.com/hexo-theme-material-indigo@latest/css/style.css">
    <script>window.lazyScripts=[]</script>

    <!-- custom head -->
    

</head>

<body>
    <div id="loading" class="active"></div>

    <aside id="menu" class="hide">
  <div class="inner flex-row-vertical">
    <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menu-off">
        <i class="icon icon-lg icon-close"></i>
    </a>
    <div class="brand-wrap" style="background-image:url(/img/brand.jpg)">
      <div class="brand">
        <a href="/" class="avatar waves-effect waves-circle waves-light">
          <img src="/img/avatar.jpg">
        </a>
        <hgroup class="introduce">
          <h5 class="nickname">lafen</h5>
          <a href="mailto:1031822863@qq.com" title="1031822863@qq.com" class="mail">1031822863@qq.com</a>
        </hgroup>
      </div>
    </div>
    <div class="scroll-wrap flex-col">
      <ul class="nav">
        
            <li class="waves-block waves-effect">
              <a href="/">
                <i class="icon icon-lg icon-home"></i>
                home
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/archives">
                <i class="icon icon-lg icon-archives"></i>
                Archives
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/tags">
                <i class="icon icon-lg icon-tags"></i>
                Tags
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/categories">
                <i class="icon icon-lg icon-th-list"></i>
                Categories
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://github.com/zhongxiaotian" target="_blank">
                <i class="icon icon-lg icon-github"></i>
                Github
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="http://www.weibo.com/" target="_blank">
                <i class="icon icon-lg icon-weibo"></i>
                Weibo
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://gitee.com/lafen" target="_blank">
                <i class="icon icon-lg icon-link"></i>
                Gitee
              </a>
            </li>
        
      </ul>
    </div>
  </div>
</aside>

    <main id="main">
        <header class="top-header" id="header">
    <div class="flex-row">
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light on" id="menu-toggle">
          <i class="icon icon-lg icon-navicon"></i>
        </a>
        <div class="flex-col header-title ellipsis">vue-源码笔记</div>
        
        <div class="search-wrap" id="search-wrap">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
                <i class="icon icon-lg icon-chevron-left"></i>
            </a>
            <input type="text" id="key" class="search-input" autocomplete="off" placeholder="输入感兴趣的关键字">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="search">
                <i class="icon icon-lg icon-search"></i>
            </a>
        </div>
        
        
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menuShare">
            <i class="icon icon-lg icon-share-alt"></i>
        </a>
        
    </div>
</header>
<header class="content-header post-header">

    <div class="container fade-scale">
        <h1 class="title">vue-源码笔记</h1>
        <h5 class="subtitle">
            
                <time datetime="2019-11-17T13:23:12.000Z" itemprop="datePublished" class="page-time">
  2019-11-17
</time>


	<ul class="article-category-list"><li class="article-category-list-item"><a class="article-category-list-link" href="/categories/vue/">vue</a><ul class="article-category-list-child"><li class="article-category-list-item"><a class="article-category-list-link" href="/categories/vue/learning/">learning</a><ul class="article-category-list-child"><li class="article-category-list-item"><a class="article-category-list-link" href="/categories/vue/learning/note/">note</a></li></ul></li></ul></li></ul>

            
        </h5>
    </div>

    


</header>


<div class="container body-wrap">
    
    <aside class="post-widget">
        <nav class="post-toc-wrap post-toc-shrink" id="post-toc">
            <h4>TOC</h4>
            <ol class="post-toc"><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#vue中操作"><span class="post-toc-number">1.</span> <span class="post-toc-text">vue中操作</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-4"><a class="post-toc-link" href="#类型判断"><span class="post-toc-number">1.1.</span> <span class="post-toc-text">类型判断</span></a></li><li class="post-toc-item post-toc-level-4"><a class="post-toc-link" href="#bind"><span class="post-toc-number">1.2.</span> <span class="post-toc-text">bind</span></a></li><li class="post-toc-item post-toc-level-4"><a class="post-toc-link" href="#对象的属性的监听"><span class="post-toc-number">1.3.</span> <span class="post-toc-text">对象的属性的监听</span></a></li><li class="post-toc-item post-toc-level-4"><a class="post-toc-link" href="#数组的拦截方法"><span class="post-toc-number">1.4.</span> <span class="post-toc-text">数组的拦截方法</span></a></li><li class="post-toc-item post-toc-level-4"><a class="post-toc-link" href="#this-set-与-this-delete"><span class="post-toc-number">1.5.</span> <span class="post-toc-text">this.$set 与 this.$delete</span></a></li><li class="post-toc-item post-toc-level-4"><a class="post-toc-link" href="#this-nextTick"><span class="post-toc-number">1.6.</span> <span class="post-toc-text">this.$nextTick</span></a></li><li class="post-toc-item post-toc-level-4"><a class="post-toc-link" href="#渐进式如何理解"><span class="post-toc-number">1.7.</span> <span class="post-toc-text">渐进式如何理解</span></a></li></ol></li></ol>
        </nav>
    </aside>


<article id="post-vue-源码笔记/vue-源码笔记" class="post-article article-type-post fade" itemprop="blogPost">

    <div class="post-card">
        <h1 class="post-card-title">vue-源码笔记</h1>
        <div class="post-meta">
            <time class="post-time" title="2019-11-17 21:23:12" datetime="2019-11-17T13:23:12.000Z" itemprop="datePublished">2019-11-17</time>

            
	<ul class="article-category-list"><li class="article-category-list-item"><a class="article-category-list-link" href="/categories/vue/">vue</a><ul class="article-category-list-child"><li class="article-category-list-item"><a class="article-category-list-link" href="/categories/vue/learning/">learning</a><ul class="article-category-list-child"><li class="article-category-list-item"><a class="article-category-list-link" href="/categories/vue/learning/note/">note</a></li></ul></li></ul></li></ul>



            
<span id="busuanzi_container_page_pv" title="文章总阅读量" style="display:none">
    <i class="icon icon-eye icon-pr"></i><span id="busuanzi_value_page_pv"></span>
</span>


        </div>
        <div class="post-content" id="post-content" itemprop="postContent">
            <h3 id="vue中操作"><a href="#vue中操作" class="headerlink" title="vue中操作"></a>vue中操作</h3><h4 id="类型判断"><a href="#类型判断" class="headerlink" title="类型判断"></a>类型判断</h4><ol>
<li>快速检查是否是一个对象类型</li>
</ol>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">isObject</span> (<span class="params">obj</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">return</span> obj !== <span class="literal">null</span> &amp;&amp; <span class="keyword">typeof</span> obj === <span class="string">'object'</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<ol start="2">
<li>快速检查类型，利用 <code>toString</code> ，然后使用 <code>slice</code> 截取关键字</li>
</ol>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> _toString = <span class="built_in">Object</span>.prototype.toString;</span><br><span class="line"><span class="comment">// 类型判断, 会返回Array，Function，String，Object，Reg等字符串</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">toRawType</span> (<span class="params">value</span>) </span>&#123;</span><br><span class="line">    <span class="comment">// slice 从索引 8 开始，到最后一个元素（不含）截取字符串</span></span><br><span class="line">    <span class="keyword">return</span> _toString.call(value).slice(<span class="number">8</span>, <span class="number">-1</span>)</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 纯对象类型</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">isPlainObject</span> (<span class="params">obj</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">return</span> _toString.call(obj) === <span class="string">'[object Object]'</span></span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">// 正则</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">isRegExp</span> (<span class="params">v</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">return</span> _toString.call(v) === <span class="string">'[object RegExp]'</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<ol start="3">
<li>判断是否 <code>promise</code> 对象</li>
</ol>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 是否已定义</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">isDef</span> (<span class="params">v</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">return</span> v !== <span class="literal">undefined</span> &amp;&amp; v !== <span class="literal">null</span></span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">isPromise</span> (<span class="params">val</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">return</span> (</span><br><span class="line">      isDef(val) &amp;&amp;</span><br><span class="line">      <span class="keyword">typeof</span> val.then === <span class="string">'function'</span> &amp;&amp;</span><br><span class="line">      <span class="keyword">typeof</span> val.catch === <span class="string">'function'</span></span><br><span class="line">    )</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<ol start="4">
<li>转换字符串方法 <code>toString</code> </li>
</ol>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> _toString = <span class="built_in">Object</span>.prototype.toString;</span><br><span class="line"><span class="comment">// 对象或数组使用 JSON.stringify ，否则使用 String</span></span><br><span class="line"><span class="comment">// JSON.stringify 的第二个参数为用于转换结果的函数或数组，2 为缩进</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">toString</span> (<span class="params">val</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">return</span> val == <span class="literal">null</span></span><br><span class="line">      ? <span class="string">''</span></span><br><span class="line">      : <span class="built_in">Array</span>.isArray(val) || (isPlainObject(val) &amp;&amp; val.toString === _toString)</span><br><span class="line">        ? <span class="built_in">JSON</span>.stringify(val, <span class="literal">null</span>, <span class="number">2</span>)</span><br><span class="line">        : <span class="built_in">String</span>(val)</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<ol start="5">
<li>一次性函数</li>
</ol>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">once</span>(<span class="params">fn</span>) </span>&#123;</span><br><span class="line">    <span class="comment">// 第一次调用 once 返回的函数可以 apply 调用</span></span><br><span class="line">    <span class="keyword">var</span> called = <span class="literal">false</span></span><br><span class="line">    <span class="keyword">return</span> <span class="function"><span class="keyword">function</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">        <span class="keyword">if</span>(!called) &#123;</span><br><span class="line">            <span class="comment">// 利用闭包，将标志置为 true，则下次不可执行</span></span><br><span class="line">            called = <span class="literal">true</span></span><br><span class="line">            fn.apply(<span class="keyword">this</span>, <span class="built_in">arguments</span>)</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<ol start="6">
<li>判断是否为内置函数</li>
</ol>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 内置函数调用toString()方法，为'function xxx() &#123; [native code] &#125;'</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">isNative</span> (<span class="params">Ctor</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">return</span> <span class="keyword">typeof</span> Ctor === <span class="string">'function'</span> &amp;&amp; <span class="regexp">/native code/</span>.test(Ctor.toString())</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h4 id="bind"><a href="#bind" class="headerlink" title="bind"></a>bind</h4><p><code>vue</code> 中 <code>bind</code> 方法的实现，根据传入的参数个数，使用 <code>apply</code> 或者 <code>call</code> 实现 <code>this</code> 绑定，在内部返回一个函数 <code>boundFn</code></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// vue 中通过 apply 和 call 实现的 bind 函数</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">polyfillBind</span>(<span class="params">fn, ctx</span>) </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">function</span> <span class="title">boundFn</span>(<span class="params">a</span>) </span>&#123;</span><br><span class="line">        <span class="keyword">var</span> l = <span class="built_in">arguments</span>.length;</span><br><span class="line">        <span class="keyword">return</span> l</span><br><span class="line">        	? l &gt; <span class="number">1</span></span><br><span class="line">        		? fn.apply(ctx, <span class="built_in">arguments</span>)</span><br><span class="line">        		: fn.call(ctx, a)</span><br><span class="line">        	: fn.call(ctx)</span><br><span class="line">    &#125;</span><br><span class="line">    boundFn._length = fn.length;</span><br><span class="line">    <span class="keyword">return</span> boundFn</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">// 原生 bind</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">nativeBind</span>(<span class="params">fn, ctx</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">return</span> fn.bind(ctx)</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">// 赋值给 bind</span></span><br><span class="line"><span class="keyword">var</span> bind = <span class="built_in">Function</span>.prototype.bind</span><br><span class="line">	? nativeBind</span><br><span class="line">	: polyfillBind;</span><br></pre></td></tr></table></figure>
<h4 id="对象的属性的监听"><a href="#对象的属性的监听" class="headerlink" title="对象的属性的监听"></a>对象的属性的监听</h4><h4 id="数组的拦截方法"><a href="#数组的拦截方法" class="headerlink" title="数组的拦截方法"></a>数组的拦截方法</h4><h4 id="this-set-与-this-delete"><a href="#this-set-与-this-delete" class="headerlink" title="this.$set 与 this.$delete"></a><code>this.$set</code> 与 <code>this.$delete</code></h4><p>对于<strong>对象</strong>监听可以使用<code>defineproperty</code>来讲对象属性转换成响应式，但是却不能监听到对象是否<strong>增加</strong>和<strong>删除</strong>了属性，数组也只能使用<strong>拦截方法</strong>来实现响应式，但是同样无法监听数组元素的添加和删除，于是<code>vue</code>提供了 <code>this.$set</code> 和 <code>this.$delete</code> 方法，将其挂载到 <code>Vue</code> 的原型上</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">Vue.prototype.$set = set;</span><br><span class="line">Vue.prototype.$<span class="keyword">delete</span> = del;</span><br></pre></td></tr></table></figure>
<p>具体实现方法如下</p>
<ol>
<li>set</li>
</ol>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 方法去除了些检查警告</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">set</span> (<span class="params">target, key, val</span>) </span>&#123;</span><br><span class="line">    <span class="comment">// 对数组的处理</span></span><br><span class="line">    <span class="comment">// 如果是超出数组长度范围，则增加数组长度，然后通过 splice 方法替换</span></span><br><span class="line">    <span class="comment">// splice 方法是数组的拦截方法，所以会监听到修改</span></span><br><span class="line">    <span class="keyword">if</span> (<span class="built_in">Array</span>.isArray(target) &amp;&amp; isValidArrayIndex(key)) &#123;</span><br><span class="line">      target.length = <span class="built_in">Math</span>.max(target.length, key);</span><br><span class="line">      target.splice(key, <span class="number">1</span>, val);</span><br><span class="line">      <span class="keyword">return</span> val</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">// 如果已经是该对象的属性了，说明已经监听了该属性，则直接赋值即可</span></span><br><span class="line">    <span class="keyword">if</span> (key <span class="keyword">in</span> target &amp;&amp; !(key <span class="keyword">in</span> <span class="built_in">Object</span>.prototype)) &#123;</span><br><span class="line">      target[key] = val;</span><br><span class="line">      <span class="keyword">return</span> val</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">// 目标不是响应式数据，直接赋值返回即可</span></span><br><span class="line">    <span class="keyword">var</span> ob = (target).__ob__;</span><br><span class="line">    <span class="keyword">if</span> (!ob) &#123;</span><br><span class="line">      target[key] = val;</span><br><span class="line">      <span class="keyword">return</span> val</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">// 设置该属性为响应式，并手动触发通知</span></span><br><span class="line">    defineReactive$$<span class="number">1</span>(ob.value, key, val);</span><br><span class="line">    ob.dep.notify();</span><br><span class="line">    <span class="keyword">return</span> val</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<ol start="2">
<li>del</li>
</ol>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 同样去除一些检查警告</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">del</span> (<span class="params">target, key</span>) </span>&#123;</span><br><span class="line">    <span class="comment">// 数组直接使用拦截方法 splice</span></span><br><span class="line">    <span class="keyword">if</span> (<span class="built_in">Array</span>.isArray(target) &amp;&amp; isValidArrayIndex(key)) &#123;</span><br><span class="line">      target.splice(key, <span class="number">1</span>);</span><br><span class="line">      <span class="keyword">return</span></span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">// 对象是否是响应式</span></span><br><span class="line">    <span class="keyword">var</span> ob = (target).__ob__;</span><br><span class="line">    <span class="comment">// 删除一个不存在的属性，直接返回</span></span><br><span class="line">    <span class="keyword">if</span> (!hasOwn(target, key)) &#123;</span><br><span class="line">      <span class="keyword">return</span></span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">// 直接 delete，然后手动更新通知</span></span><br><span class="line">    <span class="keyword">delete</span> target[key];</span><br><span class="line">    <span class="comment">// 不是响应式，则直接返回</span></span><br><span class="line">    <span class="keyword">if</span> (!ob) &#123;</span><br><span class="line">      <span class="keyword">return</span></span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">// 手动更新通知</span></span><br><span class="line">    ob.dep.notify();</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h4 id="this-nextTick"><a href="#this-nextTick" class="headerlink" title="this.$nextTick"></a><code>this.$nextTick</code></h4><p><code>$nextTick</code> 同样是挂载到<code>Vue</code> 的原型对象上</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">renderMixin</span>(<span class="params">Vue</span>) </span>&#123;</span><br><span class="line">    Vue.prototype.$nextTick = <span class="function"><span class="keyword">function</span>(<span class="params">fn</span>) </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> nextTick(fn, <span class="keyword">this</span>)</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><code>nextTick</code> 的声明</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// nextTick 方法</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">nextTick</span> (<span class="params">cb, ctx</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">var</span> _resolve;</span><br><span class="line">    <span class="comment">// 将回调存入队列中，并没有直接执行 cb 函数</span></span><br><span class="line">    <span class="comment">// callbacks 仅仅是一个数组</span></span><br><span class="line">    callbacks.push(<span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</span><br><span class="line">      <span class="keyword">if</span> (cb) &#123;</span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">          cb.call(ctx);</span><br><span class="line">        &#125; <span class="keyword">catch</span> (e) &#123;</span><br><span class="line">          handleError(e, ctx, <span class="string">'nextTick'</span>);</span><br><span class="line">        &#125;</span><br><span class="line">      &#125; <span class="keyword">else</span> <span class="keyword">if</span> (_resolve) &#123;</span><br><span class="line">        _resolve(ctx);</span><br><span class="line">      &#125;</span><br><span class="line">    &#125;);</span><br><span class="line">    <span class="keyword">if</span> (!pending) &#123;</span><br><span class="line">      pending = <span class="literal">true</span>; <span class="comment">// pending 保证执行期间不添加新的回调到队列中</span></span><br><span class="line">      timerFunc(); <span class="comment">// 执行函数</span></span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">//</span></span><br><span class="line">    <span class="keyword">if</span> (!cb &amp;&amp; <span class="keyword">typeof</span> <span class="built_in">Promise</span> !== <span class="string">'undefined'</span>) &#123;</span><br><span class="line">      <span class="keyword">return</span> <span class="keyword">new</span> <span class="built_in">Promise</span>(<span class="function"><span class="keyword">function</span> (<span class="params">resolve</span>) </span>&#123;</span><br><span class="line">        _resolve = resolve; <span class="comment">// 将resolve回调赋值给_resolve</span></span><br><span class="line">      &#125;)</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>可以看到传入的 <code>cb</code> 回调并没有直接执行，而是使用匿名函数包装之后，压入了一个执行队列 <code>callbacks</code> 中保存，<code>callbacks</code> 仅仅是个数组而已，用于模拟任务队列，再继续看看 <code>timerFunc</code> 是什么</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> timerFunc;</span><br><span class="line"><span class="keyword">if</span> (<span class="keyword">typeof</span> <span class="built_in">Promise</span> !== <span class="string">'undefined'</span> &amp;&amp; isNative(<span class="built_in">Promise</span>)) &#123;</span><br><span class="line">    <span class="comment">// 优先使用 promise 来触发宏任务</span></span><br><span class="line">    <span class="keyword">var</span> p = <span class="built_in">Promise</span>.resolve();</span><br><span class="line">    <span class="comment">// timerFunc 赋值</span></span><br><span class="line">    timerFunc = <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</span><br><span class="line">      p.then(flushCallbacks);</span><br><span class="line">      <span class="comment">// 强制刷新微任务队列</span></span><br><span class="line">      <span class="keyword">if</span> (isIOS) &#123; setTimeout(noop); &#125;</span><br><span class="line">    &#125;;</span><br><span class="line">    isUsingMicroTask = <span class="literal">true</span>; <span class="comment">// 使用微任务标志</span></span><br><span class="line">  &#125; <span class="keyword">else</span> <span class="keyword">if</span> (!isIE &amp;&amp; <span class="keyword">typeof</span> MutationObserver !== <span class="string">'undefined'</span> &amp;&amp; (</span><br><span class="line">    <span class="comment">// 如无 promise ，则判断是否有 MutationObserver</span></span><br><span class="line">    isNative(MutationObserver) ||</span><br><span class="line">    <span class="comment">// PhantomJS and iOS 7.x</span></span><br><span class="line">    MutationObserver.toString() === <span class="string">'[object MutationObserverConstructor]'</span></span><br><span class="line">  )) &#123;</span><br><span class="line">    <span class="comment">// 无 promise 时使用MutationObserver</span></span><br><span class="line">    <span class="keyword">var</span> counter = <span class="number">1</span>;</span><br><span class="line">    <span class="keyword">var</span> observer = <span class="keyword">new</span> MutationObserver(flushCallbacks);</span><br><span class="line">    <span class="keyword">var</span> textNode = <span class="built_in">document</span>.createTextNode(<span class="built_in">String</span>(counter));</span><br><span class="line">    observer.observe(textNode, &#123;</span><br><span class="line">      characterData: <span class="literal">true</span></span><br><span class="line">    &#125;);</span><br><span class="line">    <span class="comment">// timerFunc 赋值</span></span><br><span class="line">    timerFunc = <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</span><br><span class="line">      counter = (counter + <span class="number">1</span>) % <span class="number">2</span>;</span><br><span class="line">      textNode.data = <span class="built_in">String</span>(counter);</span><br><span class="line">    &#125;;</span><br><span class="line">    isUsingMicroTask = <span class="literal">true</span>; <span class="comment">// 使用微任务标志</span></span><br><span class="line">  &#125; <span class="keyword">else</span> <span class="keyword">if</span> (<span class="keyword">typeof</span> setImmediate !== <span class="string">'undefined'</span> &amp;&amp; isNative(setImmediate)) &#123;</span><br><span class="line">    <span class="comment">// promise MutationObserver 都没有，则降级为宏任务</span></span><br><span class="line">    <span class="comment">// 先使用 setImmediate 将回调添加进宏任务队列</span></span><br><span class="line">    <span class="comment">// 如果再没有 setImmediate，则只能使用setTimeout</span></span><br><span class="line">    timerFunc = <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</span><br><span class="line">      setImmediate(flushCallbacks); <span class="comment">// flushCallbacks 作为回调</span></span><br><span class="line">    &#125;;</span><br><span class="line">  &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">    <span class="comment">// 降级为宏任务 setTimeout</span></span><br><span class="line">    timerFunc = <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</span><br><span class="line">      setTimeout(flushCallbacks, <span class="number">0</span>); <span class="comment">// flushCallbacks 作为回调</span></span><br><span class="line">    &#125;;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>可以看到的是，其中包含了几种任务的实现（<code>timerFunc</code> 赋值），包括 <code>promise</code>、<code>MutationObserver</code>、<code>setImmediate</code> 与 <code>setTimeout</code> ，依次按顺序赋值给 <code>timerFunc</code>，优先使用<strong>微任务</strong>，如果运行环境不支持，则降级为<strong>宏任务</strong>，在下一次事件循环中调用，宏任务与微任务的区别，可以看另外一篇文章<a href="[https://lafen.gitee.io/2019/09/27/js-%E5%AE%8F%E4%BB%BB%E5%8A%A1%E5%92%8C%E5%BE%AE%E4%BB%BB%E5%8A%A1/js-%E5%AE%8F%E4%BB%BB%E5%8A%A1%E5%92%8C%E5%BE%AE%E4%BB%BB%E5%8A%A1/](https://lafen.gitee.io/2019/09/27/js-宏任务和微任务/js-宏任务和微任务/">《js-宏任务和微任务》</a> )</p>
<p>同时可以看到，<code>timerFunc</code> 在任务队列中注册的是 <code>flushCallbacks</code>  ，再继续找<code>flushCallbacks</code> 函数中干了什么</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 是否使用微任务</span></span><br><span class="line"><span class="keyword">var</span> isUsingMicroTask = <span class="literal">false</span>;</span><br><span class="line"><span class="comment">// 任务队列</span></span><br><span class="line"><span class="keyword">var</span> callbacks = [];</span><br><span class="line"><span class="keyword">var</span> pending = <span class="literal">false</span>;</span><br><span class="line"><span class="comment">// 重置 pending状态， 取出回调函数执行</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">flushCallbacks</span> (<span class="params"></span>) </span>&#123;</span><br><span class="line">    pending = <span class="literal">false</span>; <span class="comment">// pedding 状态</span></span><br><span class="line">    <span class="keyword">var</span> copies = callbacks.slice(<span class="number">0</span>); <span class="comment">// 从任务队列中取出所有回调执行</span></span><br><span class="line">    callbacks.length = <span class="number">0</span>; <span class="comment">// 清空任务队列</span></span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">var</span> i = <span class="number">0</span>; i &lt; copies.length; i++) &#123;</span><br><span class="line">      copies[i](); <span class="comment">// 执行所有回调</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>可以看到 <code>flushCallbacks</code> 也很简单，就是取出任务队列 <code>callbacks</code> 中的函数，依次执行而已，至此就是 <code>nextTick</code> 的全部代码了</p>
<h4 id="渐进式如何理解"><a href="#渐进式如何理解" class="headerlink" title="渐进式如何理解"></a>渐进式如何理解</h4><p>就是把框架分层，无论是已有的多页面应用，还是新开始的单页面应用，<code>vue</code> 框架都能满足你的开发需求供你选择。</p>
<p><code>vue</code> 最核心的部分是<strong>视图渲染</strong>，然后往外是<strong>组件机制</strong>，再加上<strong>路由机制</strong>、<strong>状态管理</strong>以及<strong>构建工具</strong>，你可以层层选择用来构建自己的应用，也可以使用一整套全家桶来开发你的应用。</p>
<p>未完待续…</p>

        </div>

        <blockquote class="post-copyright">
    
    <div class="content">
        
<span class="post-time">
    最后更新时间：<time datetime="2019-11-24T06:57:04.131Z" itemprop="dateUpdated">2019-11-24 14:57:04</time>
</span><br>


        
        关于学习类文章网上已经有非常多，而此处文章都是我在学习过程中整理摘录的笔记，参考文章可以点击文末的参考链接进行查阅
        
    </div>
    
    <footer>
        <a href="https://lafen.gitee.io">
            <img src="/img/avatar.jpg" alt="lafen">
            lafen
        </a>
    </footer>
</blockquote>

        
<div class="page-reward">
    <a id="rewardBtn" href="javascript:;" class="page-reward-btn waves-effect waves-circle waves-light">赏</a>
</div>



        <div class="post-footer">
            
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/learning/">learning</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/note/">note</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/vue/">vue</a></li></ul>


            
<div class="page-share-wrap">
    

<div class="page-share" id="pageShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=https://lafen.gitee.io/2019/11/17/vue-源码笔记/vue-源码笔记/&title=《vue-源码笔记》 — lafen&pic=https://lafen.gitee.io/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=https://lafen.gitee.io/2019/11/17/vue-源码笔记/vue-源码笔记/&title=《vue-源码笔记》 — lafen&source=lafen's personal blog" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https://lafen.gitee.io/2019/11/17/vue-源码笔记/vue-源码笔记/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《vue-源码笔记》 — lafen&url=https://lafen.gitee.io/2019/11/17/vue-源码笔记/vue-源码笔记/&via=https://lafen.gitee.io" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=https://lafen.gitee.io/2019/11/17/vue-源码笔记/vue-源码笔记/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>



    <a href="javascript:;" id="shareFab" class="page-share-fab waves-effect waves-circle">
        <i class="icon icon-share-alt icon-lg"></i>
    </a>
</div>



        </div>
    </div>

    
<nav class="post-nav flex-row flex-justify-between">
  
    <div class="waves-block waves-effect prev">
      <a href="/2019/11/20/vue-项目记录/vue-项目记录/" id="post-prev" class="post-nav-link">
        <div class="tips"><i class="icon icon-angle-left icon-lg icon-pr"></i> Prev</div>
        <h4 class="title">vue-项目记录</h4>
      </a>
    </div>
  

  
    <div class="waves-block waves-effect next">
      <a href="/2019/11/17/js-数组与递归思想/js-数组与递归思想/" id="post-next" class="post-nav-link">
        <div class="tips">Next <i class="icon icon-angle-right icon-lg icon-pl"></i></div>
        <h4 class="title">js-数组与递归思想</h4>
      </a>
    </div>
  
</nav>



    




















</article>

<div id="reward" class="page-modal reward-lay">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <h3 class="reward-title">
        <i class="icon icon-quote-left"></i>
        打笔巨款？~
        <i class="icon icon-quote-right"></i>
    </h3>
    <div class="reward-content">
        
        <div class="reward-code">
            <img id="rewardCode" src="/img/wechat.jpg" alt="打赏二维码">
        </div>
        
        <label class="reward-toggle">
            <input id="rewardToggle" type="checkbox" class="reward-toggle-check" data-wechat="/img/wechat.jpg" data-alipay="/img/alipay.jpg">
            <div class="reward-toggle-ctrol">
                <span class="reward-toggle-item wechat">微信</span>
                <span class="reward-toggle-label"></span>
                <span class="reward-toggle-item alipay">支付宝</span>
            </div>
        </label>
        
    </div>
</div>



</div>

        <footer class="footer">
    <div class="top">
        
<p>
    <span id="busuanzi_container_site_uv" style="display:none">
        站点总访客数：<span id="busuanzi_value_site_uv"></span>
    </span>
    <span id="busuanzi_container_site_pv" style="display:none">
        站点总访问量：<span id="busuanzi_value_site_pv"></span>
    </span>
</p>


        <p>
            
                <span><a href="/atom.xml" target="_blank" class="rss" title="rss"><i class="icon icon-lg icon-rss"></i></a></span>
            
            <span>博客内容遵循 <a rel="license" href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh">知识共享 署名 - 非商业性 - 相同方式共享 4.0 国际协议</a></span>
        </p>
    </div>
    <div class="bottom">
        <p><span>lafen &copy; 2019 - 2020</span>
            <span>
                
                Power by <a href="http://hexo.io/" target="_blank">Hexo</a> Theme <a href="https://github.com/yscoder/hexo-theme-indigo" target="_blank">indigo</a>
            </span>
        </p>
    </div>
</footer>

    </main>
    <div class="mask" id="mask"></div>
<a href="javascript:;" id="gotop" class="waves-effect waves-circle waves-light"><span class="icon icon-lg icon-chevron-up"></span></a>



<div class="global-share" id="globalShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=https://lafen.gitee.io/2019/11/17/vue-源码笔记/vue-源码笔记/&title=《vue-源码笔记》 — lafen&pic=https://lafen.gitee.io/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=https://lafen.gitee.io/2019/11/17/vue-源码笔记/vue-源码笔记/&title=《vue-源码笔记》 — lafen&source=lafen's personal blog" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https://lafen.gitee.io/2019/11/17/vue-源码笔记/vue-源码笔记/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《vue-源码笔记》 — lafen&url=https://lafen.gitee.io/2019/11/17/vue-源码笔记/vue-源码笔记/&via=https://lafen.gitee.io" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=https://lafen.gitee.io/2019/11/17/vue-源码笔记/vue-源码笔记/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>


<div class="page-modal wx-share" id="wxShare">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <p>扫一扫，分享到微信</p>
    <img src="" alt="微信分享二维码">
</div>




    <script src="//cdn.bootcss.com/node-waves/0.7.4/waves.min.js"></script>
<script>
var BLOG = { ROOT: '/', SHARE: true, REWARD: true };


</script>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/main.min.js"></script>


<div class="search-panel" id="search-panel">
    <ul class="search-result" id="search-result"></ul>
</div>
<template id="search-tpl">
<li class="item">
    <a href="{path}" class="waves-block waves-effect">
        <div class="title ellipsis" title="{title}">{title}</div>
        <div class="flex-row flex-middle">
            <div class="tags ellipsis">
                {tags}
            </div>
            <time class="flex-col time">{date}</time>
        </div>
    </a>
</li>
</template>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/search.min.js" async></script>






<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>



<script>
(function() {
    var OriginTitile = document.title, titleTime;
    document.addEventListener('visibilitychange', function() {
        if (document.hidden) {
            document.title = '死鬼去哪里了！';
            clearTimeout(titleTime);
        } else {
            document.title = '(つェ⊂)咦!又好了!';
            titleTime = setTimeout(function() {
                document.title = OriginTitile;
            },2000);
        }
    });
})();
</script>



<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"scale":1,"jsonPath":"/live2dw/assets/shizuku.model.json"},"display":{"positon":"right","width":150,"height":300},"mobile":{"show":true,"scale":0.8},"react":{"opacity":0.8,"opacityDefault":0.8,"opacityOnHover":0.6},"log":false});</script></body>
</html>
